package rpc.frame.server.config.zk;

import org.I0Itec.zkclient.ZkClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import rpc.frame.server.config.RpcServerConfiguration;

import javax.annotation.Resource;

/**
 * 获取zk 客户端
 */
@Configuration
public class ServerZkConfiguration {

    @Resource
    private RpcServerConfiguration rpcServerConfiguration;

    /**
     * 根据配置生成 zk客户端
     * @return
     */
    @Bean
    public ZkClient zkClient(){
        return new ZkClient(rpcServerConfiguration.getZkAddr(),rpcServerConfiguration.getConnectTimeout());
    }
}
